import {reqAddressInfo,reqOrderInfo} from "../../api"

const actions = {
	//获取用户地址信息
	async getUserAddress({commit}){
		let result = await reqAddressInfo()
		// console.log(result)
		if(result.code==200){
			commit('GETUSERADDRESS',result.data)
			return 'ok'
		}else{
			return Promise.reject(new Error('faile'))
		}
		
	},
	async getUserOrderInfo({commit}){
		let result = await reqOrderInfo()
		console.log(result)
		if(result.code==200){
			commit('GETUSERORDERINFO',result.data)
		}
		
	}
}

const mutations = {
	GETUSERADDRESS(state,addressInfo){
		state.addressInfo = addressInfo
	},
	GETUSERORDERINFO(state,orderInfo){
		// console.log(orderInfo)
		state.orderInfo = orderInfo
	}
}

const getters = {
	
}

const state = {
	addressInfo:[],
	orderInfo:{}
}

export default {
	state,
	mutations,
	actions,
	getters
}